<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <!-- 头部区域 -->
        <!--搜索框-->
        <ul class="layui-nav layui-layout-left my-search">
            <li class="layui-nav-item layadmin-flexible" lay-unselect>
                <a href="javascript:;" layadmin-event="flexible" title="侧边伸缩">
                    <i class="layui-icon layui-icon-shrink-right" id="LAY_app_flexible"></i>
                </a>
            </li>
            <li class="layui-nav-item layui-hide-xs" lay-unselect style="width: 500px">
                <!--                <input  type="text" placeholder="搜索..." autocomplete="off"-->
                <!--                       class="layui-input layui-input-search"-->
                <!--                       layadmin-event="serach" lay-action="template/search/keywords=">-->
                <!--                <input name="list" type="text" placeholder="搜索..."-->
                <!--                       autocomplete="off" class="layui-input layui-input-search">-->
                <div>
                    <style>
                        .selectId {
                            width: 300px;
                        }

                        .selectId input {
                            height: 50px;
                            padding: 1px 5px;
                            border-radius: 3px;
                            background: rgba(0, 0, 0, 0);
                            /*width: calc(100% - 12px + 50px);*/
                            width: 500px;
                            color: #6e6e6e;
                            outline-color: #e2e2e2;
                            border: 0px solid #e2e2e2;
                        }

                        .selectId dl {
                            border: 1px solid #e2e2e2;
                            border-radius: 5px;
                            /*width: calc(100% - 12px + 50px);*/
                            width: 508px;
                            /*background-color: #e0e0e0;*/
                            background-color: #ffffff;
                            /*margin: 1px 0px;*/
                            max-height: 320px;
                            overflow-x: hidden;
                            /*white-space: nowrap;*/
                            color: #666;
                        }

                        .selectId dl dd {
                            margin-left: 0px;
                            padding-left: 10px;
                        }

                        .selectId dl dd:hover {
                            background-color: #c1c1c1;
                            color: white;
                            /*color: black;*/
                        }

                        .AD {
                            width: 210px;
                            margin-left: 40px;
                            overflow-y: auto;
                            max-height: 200px;
                            border: 2px solid #5fb878;
                            border-radius: 6px;
                            padding: 1px 2px;
                        }
                    </style>
                    <div class="qwe">
                        <div class="selectId">
                            <input class="layui-input my-input" type="text" placeholder="模块搜索..."
                                   autocomplete="off">
                        </div>
                    </div>

                </div>

            </li>

        </ul>

        <!--右侧功能-->
        <ul class="layui-nav layui-layout-right my-search" lay-filter="layadmin-layout-right">
            <!--            <li class="layui-nav-item" lay-unselect>-->
            <!--                <script type="text/html" template-->
            <!--                        lay-done="layui.element.render('nav', 'layadmin-layout-right');">-->
            <!--                    <a href="javascript:;"-->
            <!--                       style=" cursor:default;display: inline;padding-right: 0; margin-right: 0 !important">-->
            <!--                        &lt;!&ndash;                        <i class="layui-icon">&#xe68d;</i>&ndash;&gt;-->
            <!--                        <cite>{{getTimeState()+"，"}}</cite>-->
            <!--                    </a>-->
            <!--                </script>-->
            <!--            </li>-->

            <li class="layui-nav-item" lay-unselect>
                <script type="text/html" template
                        lay-done="layui.element.render('nav', 'layadmin-layout-right');">
                    <a href="javascript:;"
                       style="display: inline;padding-left: 0; margin-left: 0 !important">
                        <cite>{{window.currentUserMsg?window.currentUserMsg.userName:"" }}</cite>
                    </a>
                    <dl class="layui-nav-child">
                        <dd style="text-align: center"><a href="javascript:;" lay-href="set/user/info">基本资料</a></dd>
                        <dd style="text-align: center"><a href="javascript:;" lay-href="set/user/password">修改密码</a></dd>
                        <!--                        <hr>-->
                        <!--                        <dd layadmin-event="logout" style="text-align: center;"><a>退出</a></dd>-->
                    </dl>
                </script>
            </li>

            <li class="layui-nav-item" lay-unselect>
                <script type="text/html" template
                        lay-done="layui.element.render('nav', 'layadmin-layout-right');">
                    <a href="javascript:;"
                       style=" cursor:default;display: inline; padding-right: 15px ;">
                        <!--                        <i class="layui-icon">&#xe68d;</i>-->
                        <!--                        {{getTimeState()+"，"}}-->
                        <cite>所属岗位：{{window.currentUserMsg?window.currentUserMsg.gwName:""}}</cite>
                        <cite style="padding-left: 10px">所属机关：{{window.currentUserMsg?window.currentUserMsg.haveGW.headSWJGMC:""}}</cite>
                    </a>
                </script>
            </li>
            <li class="layui-nav-item layui-hide-xs" lay-unselect>
                <a href="javascript:;" layadmin-event="note" style="padding-left:15px;padding-right:15px">
                    <i class="layui-icon layui-icon-note"></i>
                    <!--                    便签-->
                </a>
            </li>

            <li class="layui-nav-item layui-hide-xs" lay-unselect>
                <a href="javascript:;" layadmin-event="theme" style="padding-left:15px;padding-right:15px">
                    <i class="layui-icon layui-icon-theme"></i>
                    <!--                    主题-->
                </a>
            </li>

            <!--            <li class="layui-nav-item" lay-unselect>-->
            <!--                <a lay-href="app/message/" layadmin-event="message" style="padding-left:15px;padding-right:15px">-->
            <!--                    <i class="layui-icon layui-icon-notice"></i>-->
            <!--                    &lt;!&ndash;                    消息&ndash;&gt;-->
            <!--                    &lt;!&ndash; 如果有新消息，则显示小圆点 &ndash;&gt;-->
            <!--                    <script type="text/html" template lay-url="./json/message/new.js">-->
            <!--                        {{# if(d.data.newmsg){ }}-->
            <!--                        <span class="layui-badge-dot"></span>-->
            <!--                        {{# } }}-->
            <!--                    </script>-->
            <!--                </a>-->
            <!--            </li>-->

            <!--            全屏-->
            <li class="layui-nav-item layui-hide-xs" lay-unselect>
                <a href="javascript:;" layadmin-event="fullscreen" style="padding-left:15px;padding-right: 15px">
                    <i class="layui-icon layui-icon-screen-full"></i>
                </a>
            </li>

            <li class="layui-nav-item layui-hide-xs" lay-unselect>
                <a href="javascript:;" style="padding-left:15px;padding-right: 15px">
                    <dd layadmin-event="logout" style="text-align: center;"><i class="layui-icon layui-icon-logout"></i>
                    </dd>

                    <!--                    退出-->
                </a>
            </li>

            <!--            <li class="layui-nav-item" lay-unselect>-->
            <!--                <script type="text/html" template-->
            <!--                        lay-done="layui.element.render('nav', 'layadmin-layout-right');">-->
            <!--                    <a href="javascript:;"-->
            <!--                       style=" cursor:default;display: inline;">-->
            <!--                        &lt;!&ndash;                        <i class="layui-icon">&#xe68d;</i>&ndash;&gt;-->
            <!--                        &lt;!&ndash;                        {{getTimeState()+"，"}}&ndash;&gt;-->
            <!--                        -->
            <!--                    </a>-->
            <!--                </script>-->
            <!--            </li>-->


            <li class="layui-nav-item layui-hide-xs" lay-unselect>
                <a href="javascript:;" layadmin-event="about" style="padding-left:0;"><i
                        class="layui-icon layui-icon-more-vertical"></i></a>
            </li>
            <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-unselect>
                <a href="javascript:;" layadmin-event="more"><i class="layui-icon layui-icon-more-vertical"></i></a>
            </li>
        </ul>
    </div>
    <!--    debugger : ./json/menu.js?v={{ layui.admin.v }}  -->
    <!--    product  : {{layui.setter.hostAddr}}/portal/menutree  -->
    <!--            <script type="text/html" template lay-url="./json/menu.js?v={{ layui.admin.v }}" {{layui.setter.hostAddr}}/portal/menutree-->
    <!-- 侧边菜单 -->
    <div class="layui-side layui-side-menu" id="cbl">
        <div class="layui-side-scroll">
            <script type="text/html" template lay-url="{{layui.setter.hostAddr}}/portal/menutree"
                    lay-headers="{Authorization: '{{layui.data('layuiAdmin').Authorization}}' }"
                    lay-done="layui.element.render('nav', 'layadmin-system-side-menu');"
                    id="TPL_layout">


                <div class="layui-logo">
                    <!--                    <span><img src="{{ layui.setter.base }}style/res/template/index_logo.png" width="290px"></span>-->
                    <a href="/"><span><img src="{{ layui.setter.base }}style/res/template/index_logo2.png"
                                           width="290px"></span></a>
                </div>

                <ul class="layui-nav layui-nav-tree" lay-shrink="all" id="LAY-system-side-menu"
                    lay-filter="layadmin-system-side-menu">
                    {{#
                    var path = layui.router().path
                    ,path_href= layui.router().href
                    ,pathURL = layui.admin.correctRouter(path.join('/'))
                    ,dataName = layui.setter.response.dataName ;
                    layui.each(d[dataName], function(index, item){
                    var hasChildren = typeof item.list === 'object' && item.list.length > 0
                    ,classSelected = function(){
                    var match = path[0] == item.name || (index == 0 && !path[0])
                    || (item.jump && pathURL == layui.admin.correctRouter(item.jump)) || item.spread;
                    if(match){
                    return hasChildren ? '' : 'layui-this';
                    }
                    return '';
                    }
                    ,url = (item.jump && typeof item.jump === 'string') ? item.jump : item.name;

                    }}
                    <li data-name="{{ item.name || '' }}" data-jump="{{ item.jump || '' }}"
                        class="layui-nav-item {{ classSelected() }}">
                        <a href="javascript:;" title={{ item.title }} {{ hasChildren ?
                        '' : 'lay-href="'+ url +'"' }}
                        lay-tips="{{ item.title }}" lay-direction="2">
                        <i class="layui-icon iconfont {{ item.image }}"></i>
                        <cite style="margin-left: -5px">{{ item.title }}</cite>
                        </a>
                        {{# if(hasChildren){ }}
                        <dl class="layui-nav-child">
                            {{# layui.each(item.list, function(index2, item2){
                            var hasChildren2 = typeof item2.list == 'object' && item2.list.length > 0
                            ,classSelected2 = function(){
                            var match = (path[0] == item.name && path[1] == item2.name)
                            || (item2.jump && pathURL == layui.admin.correctRouter(item2.jump)) || item2.spread;
                            if(match){
                            return hasChildren2 ? '' : 'layui-this';
                            }
                            return '';
                            }
                            ,url2 = (item2.jump && typeof item2.jump === 'string')
                            ? item2.jump
                            : [item.name, item2.name, ''].join('/');
                            }}
                            <dd data-name="{{ item2.name  || '' }}" data-jump="{{ item2.jump || '' }}"
                                {{ classSelected2() ? (
                            'class="'+ classSelected2() +'"') : '' }}>
                            <a href="javascript:;" {{ hasChildren2 ? '' : 'lay-href="'+ url2 +'"' }}>{{ item2.title }}
                            <i style="margin-left: 5px" class="layui-icon iconfont {{ item2.image }}"></i>
                            <!--                    <cite>{{ item2.title }}</cite>-->
                            </a>
                            {{# if(hasChildren2){ }}
                            <dl class="layui-nav-child">
                                {{#
                                layui.each(item2.list, function(index3, item3){
                                var match = (path[0] == item.name && path[1] == item2.name && decodeURI(path_href) ==
                                '/'+item.name+'/'+ item2.name+'/'+item3.name+'/' + "iframe=" +
                                urlChange(item3.iframe)+'/title='+item3.title)
                                || (item3.jump && pathURL == layui.admin.correctRouter(item3.jump))
                                ,url3 = (item3.jump && typeof item3.jump === 'string')
                                ? item3.jump
                                : [item.name, item2.name, item3.name,"iframe=" +
                                urlChange(item3.iframe) +'/title='+item3.title].join('/');
                                }}
                                <dd data-name="{{ item3.name  || '' }}" data-jump="{{ item3.jump || '' }}"
                                    data-title="{{ item3.title  || '' }}"
                                    data-iframe="{{ urlChange(item3.iframe)  || '' }}"
                                    onclick="CountClick({{item3.gnmkId}})"
                                    {{ match ?
                                'class="layui-this"' : '' }}>
                                <a href="javascript:;" title={{ item3.title }} lay-href="{{ url3 }}" {{ item3.iframe ?
                                'lay-iframe="true"' : '' }}>{{ item3.title }}<i style="margin-left: 20px"
                                                                                class="layui-icon iconfont {{ item3.image }}"></i></a>
                                </dd>
                                {{# });}}
                            </dl>
                            {{# } }}
                            </dd>
                            {{# }); }}
                        </dl>
                        {{# } }}
                    </li>
                    {{# });}}
                </ul>
            </script>
        </div>
    </div>


    <!-- 页面标签 -->
    <script type="text/html" template lay-done="layui.element.render('nav', 'layadmin-pagetabs-nav')">
        {{# if(layui.setter.pageTabs){ }}
        <div class="layadmin-pagetabs" id="LAY_app_tabs">
            <div class="layui-icon layadmin-tabs-control layui-icon-prev" layadmin-event="leftPage"></div>
            <div class="layui-icon layadmin-tabs-control layui-icon-next" layadmin-event="rightPage"></div>
            <div class="layui-icon layadmin-tabs-control layui-icon-down">
                <ul class="layui-nav layadmin-tabs-select" lay-filter="layadmin-pagetabs-nav">
                    <li class="layui-nav-item" lay-unselect>
                        <a href="javascript:;"></a>
                        <dl class="layui-nav-child layui-anim-fadein">
                            <dd layadmin-event="closeThisTabs"><a href="javascript:;">关闭当前标签页</a></dd>
                            <dd layadmin-event="closeOtherTabs"><a href="javascript:;">关闭其它标签页</a></dd>
                            <!--                            <dd lay-href lay-attr="/"><a href="javascript:;"  >关闭全部标签页</a></dd>-->
                            <dd layadmin-event="closeAllTabs"><a href="javascript:;">关闭全部标签页</a></dd>
                        </dl>
                    </li>
                </ul>
            </div>
            <div class="layui-tab" lay-unauto lay-allowClose="true" lay-filter="layadmin-layout-tabs">
                <ul class="layui-tab-title" id="LAY_app_tabsheader">
                    <!--                    <li lay-id="/"><i class="layui-icon layui-icon-home"></i></li>-->
                    <li id="layui-house" lay-href><i class="layui-icon layui-icon-home"></i></li>
                </ul>
            </div>
        </div>
        {{# } }}
    </script>

    <!-- 主体内容 -->
    <div class="layui-body" id="LAY_app_body">
        <div class="layadmin-tabsbody-item layui-show" id="all-screen"></div>
    </div>
    <!-- 辅助元素，一般用于移动设备下遮罩 -->
    <div class="layadmin-body-shade" layadmin-event="shade"></div>

</div>
<script>
    layui.use(['table', 'myUtils'], function () {
        var table = layui.table,
            myUtils = layui.myUtils;
        myUtils.test();
        table.set({
            headers: { //通过 request 头传递
                Authorization: layui.data('layuiAdmin').Authorization
            }
        });

    })

    // bi打开新tag
    function createNewTag(data) {
        debugger;
        window.createNewTagQC = true  //永远打开 qc 新标签
        var ParamPair = escape(data.param),
            iframe = "/mxw/fileAccess.aspx?filename=/reports/" + data.path,
            layUri = "parentroute_qc/childroute_qc/table_qc/",
            title = data.title ? data.title : '无标题';
        ParamPair = urlChange(ParamPair);
        iframe = iframe.replace(/\//g, '%2FF');
        iframe = iframe.replace(/=/g, '%3DD');
        title = title.replace(/\//g, '\\');
        var aStr = '<a style="display: none;"  id="qc-a-lay"  title="' + title + '" lay-href="' + layUri + 'title=' + title + '/iframe=' + iframe + '&ParamPair%3DD' + ParamPair + '" lay-iframe="true">' + title + '<i style="margin-left: 20px" class="layui-icon iconfont layui-extend-wenjian"></i></ a>';
        $("body").append(aStr)
        document.getElementById("qc-a-lay").click();
        $("#qc-a-lay").remove();
    }


    // window.addEventListener('message', function (msgObj) {
    //     debugger
    //     var msg = msgObj.data.split('__Messenger__')[1];
    //     console.log("111",msg);
    // })

    // 监听iframe 跨域通信
    window.addEventListener('message', function (msgObj) {
        debugger
        var msg = msgObj.data.split('__Messenger__')[1];
        var _data = JSON.parse(msg);
        if (_data.data.jumpQc) {
            createNewTag(_data.data)
        } else if (_data.data.option === 'exportBatch') {  // 文件批量导出
            exportBatchBI(_data);
        }
    })

    // BI文件批量导出
    let tableDataList = [], sendObj = {};

    function exportBatchBI(dataBI) {
        // BI文件批量导出
        debugger;
        if (dataBI.data.command === 'prepare') {  // 重置 exportBatchContent /sendObj
            tableDataList = []
            sendObj = {};
            sendObj.zipName = dataBI.data.zipName;
        } else if (dataBI.data.command === 'append') {  //添加内容
            let tableName = dataBI.data.tableName
            let tableContent = dataBI.data.tableContent
            // 将 <tbody> </tbody> <tr </tr> <td </td> 等字符转为大写
            tableContent = tableContent.replace(/<tbody>/g, "<TBODY>")
            tableContent = tableContent.replace(/<\/tbody>/g, "</TBODY>")
            tableContent = tableContent.replace(/<tr/g, "<TR ")
            tableContent = tableContent.replace(/<\/tr>/g, "</TR>")
            tableContent = tableContent.replace(/<td/g, "<TD ")
            tableContent = tableContent.replace(/<\/td>/g, "</TD>")
            let tableId = dataBI.data.tableId
            tableDataList.push({tableId: tableId, tableName: tableName, tableContent: tableContent})
        } else if (dataBI.data.command === 'download') {
            sendObj.tableDataList = tableDataList
            // matchDownload(sendObj);
            console.log(JSON.stringify(sendObj))
            // 发送ajax请求
            $.ajax({
                async: false,    // 表示请求是否异步处理
                type: "post",    // 请求类型
                scriptCharset: 'utf-8',
                data: JSON.stringify(sendObj),
                dataType: 'json',
                url: layui.setter.hostAddr + "/portal/web/export",
                contentType: "application/json",//返回的数据类型
                beforeSend: function (XMLHttpRequest) {
                    XMLHttpRequest.setRequestHeader("Authorization", myAuthorization);
                },
                success: function (zipMsg) {
                    if (zipMsg.code === "0") {
                        let fileNamePath = zipMsg.data;
                        let fileName = fileNamePath.split("/").pop();
                        let fileHostArr = layui.setter.hostAddr.split(":").slice(0, 2);
                        let fileHost = fileHostArr.join(':');
                        let downloadLink = `<a style="display: none;"  id="zip-download" href="${fileHost + ":80" + "/userdownload/zip/" + fileName}"></a>`;
                        $("body").append(downloadLink);
                        document.getElementById("zip-download").click();
                        setTimeout(function () {
                            $("#zip-download").remove();
                        }, 4000);
                    }
                },
                error: function (err) {
                    doFail();
                }
            });
        }
    }

    // 搜索框事件
    function wordDis() {
        $('.selectId input').attr('placeholder', '')
    }

    function wordHav() {
        $('.selectId input').attr('placeholder', '模块搜索...')
    }

    // 更改iframe中的url
    function urlChange(url) {
        let urlRet = '';
        if (!url) {
            return ''
        }
        // debugger
        if (url.indexOf('?objpath=') !== -1 && url.indexOf('/mxw/add_ons') !== -1) {  //判断当前url是不是bi地址
            //http://10.0.23.99:8088/mxw/add_ons/MxwFpd/View.aspx?objpath=/reports/sjjcjyjfx_xc/test0911/top.fpd&t=0.47312702562909214
            //http://10.0.23.99:8088/mxw/fileAccess.aspx?&filename=/reports/sjjcjyjfx_xc/test0911/top.fpd&&uid=admin&pwd=admin
            // let biHost = 'http://10.0.23.99:8088'
            // biHost = biHostEncrypt(biHost)
            // window.bihost = layui.setter.biHost

            url = '/mxw/fileAccess.aspx?&filename=' + url.split('?objpath=')[1]
            let host = url.split('?')[0],
                argsStr = url.split('?')[1];
            if (argsStr) {
                let argArr = argsStr.split('&');
                let uid = '', pwd = '';
                argArr.forEach(
                    (item) => {
                        // debugger
                        // if (item.indexOf('uid') !== -1) {
                        //     uid = item.split('=')[1]
                        //     window.uid = uid;
                        // } else if (item.indexOf('pwd') !== -1) {
                        //     pwd = item.split('=')[1]
                        //     window.pwd = pwd;
                        // } else
                        if (item.indexOf('filename') !== -1) {
                            urlRet = host + '?' + item
                        }
                    }
                )
            }
        } else {
            urlRet = url // 不是BI地址的时候返回
        }
        var urlRet2 = urlRet.replace(/\//g, '%2FF');
        var urlRet3 = urlRet2.replace(/=/g, '%3DD');
        return urlRet3
    }

    // 手动再次获取三级菜单数据，模糊搜索
    var tagData = [];
    let myAuthorization = layui.data('layuiAdmin', 'Authorization')

    function buildData(dataArr) {
        if (dataArr) {
            dataArr.forEach(item1 => {
                if (item1 && item1.list) {
                    item1.list.forEach(item2 => {
                            if (item2 && item2.list) {
                                item2.list.forEach(item3 => {
                                    tagData.push(
                                        {
                                            id: [item1.name, item2.name, item3.name, "iframe=" +
                                            urlChange(item3.iframe) + '/title=' + item3.title].join('/'),
                                            name: item3.title
                                        }
                                    )
                                })
                            }
                        }
                    )
                }
            })
        }
    }


    // 创建左侧菜单
    $.ajax({
        async: false,    //表示请求是否异步处理
        type: "get",    //请求类型
        url: layui.setter.hostAddr + "/portal/menutree", //请求的 URL地址 http://10.0.23.97:8195/portal/menutree
        dataType: "json",//返回的数据类型
        beforeSend: function (XMLHttpRequest) {
            XMLHttpRequest.setRequestHeader("Authorization", myAuthorization);
        },
        success: function (data) {
            checkQuestCode(data)
            if (data.code === 0) {
                buildData(data.data)
            }
        },
        error: function (data) {
            checkQuestCode(data)
            // alert(1)

        }
    });
    // 获取当前用户信息
    $.ajax(
        {
            url: layui.setter.hostAddr + '/portal/user/loginuser',
            async: false,    //表示请求是否异步处理
            type: "get",    //请求类型
            beforeSend: function (XMLHttpRequest) {
                XMLHttpRequest.setRequestHeader("Authorization", myAuthorization);
            },
            dataType: "json",//返回的数据类型
            success: function (data) {
                debugger
                if (data.data.haveGW.SWJGMC.indexOf('国家税务总局') !== -1) {
                    data.data.haveGW.headSWJGMC = data.data.haveGW.SWJGMC.replace('国家税务总局', '')
                } else {
                    data.data.haveGW.headSWJGMC = data.data.haveGW.SWJGMC
                }
                window.currentUserMsg = data.data
            },
            error: function (msg) {
                layer.msg('网络异常')
            }
        }
    )
    debugger


    legp(".qwe").legp_search("fileId", tagData);  // 模糊搜索;
    // 根据主题修改模糊搜索主题颜色
    var indexHeadColorArr = [3, 9, 10, 11, 12, 13, 14];
    // debugger
    var themeIndex = layui.data(layui.setter.tableName).theme.color.index;
    var selectJqObj = $('.selectId > input');
    if (indexHeadColorArr.indexOf(themeIndex) !== -1) {
        selectJqObj.removeClass('mohu-input-placeholder-black')
        selectJqObj.addClass('mohu-input-placeholder-white')
    } else {
        selectJqObj.removeClass('mohu-input-placeholder-white')
        selectJqObj.addClass('mohu-input-placeholder-black')
    }


    //操作提示
    function doSuccess() {
        layer.msg('操作成功。', {
            icon: 6,
            time: 2000,

        });
    }

    function doFail() {
        layer.msg('操作失败，请联系管理员。', {
            icon: 5,
            time: 2000,
        });
    }

    // 判断时间上下午,提示语
    function getTimeState() {
        // let getTimeState = () => {
        // 获取当前时间
        let timeNow = new Date();
        // 获取当前小时
        let hours = timeNow.getHours();
        // 设置默认文字
        let text = ``;

        if (hours >= 0 && hours <= 12) {
            text = `<span class="iconfont icon-morning"> </span> 上午好`;
        } else if (hours > 12 && hours <= 24) {
            text = `<span class="iconfont icon-afternoon"> </span> 下午好`;
        }
        // 返回当前时间段对应的状态
        return text;
    }

    // biHost加密
    function biHostEncrypt(hostStr) {
        for (let i of Object.keys(layui.setter.hostEncryptDict)) {
            if (hostStr.indexOf(i) !== -1) {
                let reg = RegExp(i, 'g')
                hostStr = hostStr.replace(reg, layui.setter.hostEncryptDict[i])
            }
        }
        return hostStr
    }

    // biHost解密
    function biHostDecrypt(hostStr) {
        for (let i of Object.keys(layui.setter.hostEncryptDict)) {
            if (hostStr.indexOf(layui.setter.hostEncryptDict[i]) !== -1) {
                let reg = RegExp(layui.setter.hostEncryptDict[i], 'g')
                hostStr = hostStr.replace(reg, i)
            }
        }
        return hostStr
    }

    function checkQuestCode(data) {
        console.log('状态码: ', data.code);
        if (data.code && data.code === 40001) {
            layer.msg(
                '登录失效，请重新登录。'
            )
            setTimeout(function () {
                if (window.debug) {
                    window.location.href = 'http://10.0.23.97:8094/auth/oauth/authorize?response_type=token&client_id=client_1&redirect_uri=http://localhost:63342/XuChangFont/start/index.html?_ijt=r8gamlt0o96j6ai6l1hpsfut19#/home/home'
                } else {
                    window.location.href = layui.setter.loginLocationHref
                }
            }, 2000);
            return false
        }
        return true

    }

    var a = {}

    // 统计模块点击次数
    function CountClick(gnmkId) {
        $.ajax(
            {
                url: layui.setter.hostAddr + `/portal/gnmkhis/save?gnmkId=${gnmkId}`,
                // async: false,    //表示请求是否异步处理
                type: "get",    //请求类型
                beforeSend: function (XMLHttpRequest) {
                    XMLHttpRequest.setRequestHeader("Authorization", myAuthorization);
                },
                dataType: "json",//返回的数据类型
                success: function (data) {
                    // debugger
                    // alert(data)
                    checkQuestCode(data) //检查过期登录
                },
                error: function (msg) {
                    checkQuestCode(msg) //检查过期登录
                    layer.msg('异常:统计模块点击次数功能异常')

                }
            }
        )

    };

    // 获取当前月份
    function getCurrentMonth() {
        debugger
        var date = new Date()
        var year = date.getFullYear() + ""
        var month = date.getMonth() + 1 + ""
        if (month < 10) {
            month = "0" + month
        }
        return year + month
    };


</script>